home *** CD-ROM | disk | FTP | other *** search
- string-extensions.scm
-
- Various misc. functions that operate on strings.
- Ideas from various languages like :- CommonLisp, Icon, Python, Perl ...
- The definitions here are written for portability rather than for
- speed. If you really need fast versions, I suggest you re-code in
- a low level language like C.
-
- System : ELK
- System Specific Features :-
- provide (as in CommonLisp)
-
-
- string-center s1 width . s2
- Center the string `s1' in a string of size `width', padding on the
- left and right, if necessary with the string `s2'. If `s2' is not
- given, then spaces are used. If `s1' cannot be centered exactly,
- it is placed left of center. Truncation is then done at the left
- and right as necessary. For example :-
- (string-center "Detroit" 10 "+") == "+Detroit++"
- (string-center "Detroit" 6) == "Detroi"
- Based on the Icon function center(s1, i, s2)
- Note this does not do the same thing as the Icon function for the case
- where `width' < (string-length s1). If anybody can explain why the
- Icon function produces "etroit" in the second case, I'll be happy to
- change it.
-
- string-find-string str substr . optional-start
- Look for the string `substr' in the string `str'
- If it is there, return the position of the start of it, otherwise
- return #false
-
- string-find-char str chr . start-pos
- Look for the character `chr' in the string `str' optionally starting
- at position `start-pos'
- Returns the first position in the string at which the character is found
- of #f if the character wasn't found.
-
- string-prefix? str prefix
- Checks if the string `prefix' is a prefix of the string `str'
- If it is it returns #t
-
- string-left s1 width . s2
- Produce a string of size `width' in which the string `s1' is positioned
- at the left and `s2' is used to pad out the remaining characters to
- the right. For example :-
- (string-left "Detroit" 10 "+") == "Detroit+++"
- (string-left "Detroit" 6) == "Detroi"
- Based on the Icon function left(s1, i, s2)
-
- string-replc str copies
- Generate `copies' number of copies of the string `str'
- For example :-
- (string-replc "+*+" 3) == "+*++*++*+"
- (string-replc s 0) == ""
- Based on the Icon function repl(s, i)
- Returns : string
-
- string-replw str width
- Geneate a string which is `width' characters long consisting on the
- given string `str'. For example :-
- (string-replw "abc" 10) == "abcabcabca"
- (string-replw "abc" 1) == "a"
- (string-replw "abc" 0) == ""
- (string-replw "" 1) == ""
-
- string-reverse str
- Produces a string consisting of the characters of the string `str'
- in reverse order. For example :-
- (string-reverse "string") == "gnirts"
- (string-reverse "") == ""
- Based on the Icon function reverse(s)
- Returns : string
-
- string-right s1 width . s2
- Produce a string of size `width' in which the string `s1' is positioned
- at the right and `s2' is used to pad out the remaining characters to
- the left. For example :-
- (string-right "Detroit" 10 "+") == "+++Detroit"
- (string-right "Detroit" 6) == "etroit"
- Based on the Icon function right(s1, i, s2)
-
- string-split-whitespace str
- Returns a list of whitespace delimited words in the string `str'.
- If the string is empty or contains only whitespace, then
- it returns the empty list.
-
- string-trim-whitespace str
- Strip the leading and trailing whitespace from the string `str'
-